#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-8-13 11:13
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=14)

x_values = range(1, 1001)
y_values = [x ** 2 for x in x_values]

plt.style.use('seaborn')
fig, ax = plt.subplots()
# ax.scatter(x_values, y_values, c='red', s=3)
# ax.scatter(x_values, y_values, c=(0, 0.8, 0), s=3)  # (0, 0.8, 0)分别为 红、绿、蓝，值越接近1，指定的颜色越浅
ax.scatter(x_values, y_values, c=y_values, cmap=plt.cm.Blues, s=3)  # 使用颜色映射（设置渐变色）

# 设置图标标题并给坐标轴加上标签
ax.set_title(u'平方数的散点图', fontproperties=font_set, fontsize=24)
ax.set_xlabel(u'值', fontproperties=font_set)
ax.set_ylabel(u'值的平方', fontproperties=font_set)

# 设置刻度标记的大小
ax.tick_params(axis='both', which='major', labelsize=8)

# 设置每个坐标轴的取值范围
ax.axis([0, 1100, 0, 1_100_000])

# plt.show()
plt.savefig('catter_squares.png', bbox_inches='tight')  # bbox_inches指定将图表多余的空白区域裁减掉；如果不需要裁剪，直接省略即可



